<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="店铺管理">
<style>
    .button-large {
        font-size: 16px;
    }

    .webuploader-pick {
        background: none;
        padding: 0;
    }

    input.calendar {
        width: 160px;
    }
    #proPicture,#backPicture{
        width: 250px;
        height: 250px;
    }
</style>
<div class="xm-product">
    <div class="row">
        <div class="panel">
            <div class="panel-header">
                <a href="${basepath}/rest/manage/store/toList">返回上一级</a>
            </div>
            <div class="panel-body">
                <form id="editForm" class="form-horizontal" action="${basepath}/rest/manage/store/updateJson"
                      method="post">
                    <input type="hidden" class="control-text span-width span10" name="id" value="${e.id!}">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            店铺名称：
                        </label>

                        <div class="controls" >
                            <input type="text" class="control-text span-width span8" name="name" placeholder="请输入店铺名称"
                                   data-rules="{required : true}" value="${e.name!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            店铺地址：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="address" placeholder="请输入所在小区"
                                   data-rules="{required : true}" value="${e.address!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            店铺公告：
                        </label>

                        <div class="controls  control-row-auto">
                            <textarea name="notice"  class="control-row4 input-large" data-rules="{required : true}" placeholder="请输入内容">${e.notice!}</textarea>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>

                        <div class="controls  control-row-auto">
                            <input type="number" class="control-text span-width span8" name="phone" value="${e.phone!}" placeholder="请输入电话"
                                   data-rules="{regexp :/^1[356789]\d{9}$/},{required:true}" data-messages="{regexp:'不是有效的电话号码'}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            店铺头像：
                        </label>

                        <div class="controls" style="overflow: hidden;height: auto;padding-bottom: 20px;">
                            <input type="hidden" class="input-normal control-text " name="icon"
                                   data-rules="{required : true}" readonly style="width: 280px;" value="${e.icon}">
                            <img id="proPicture" src="/${e.icon}"
                                 style="max-width: 250px;width: 100%;max-height: 250px;">
                            <a id="pictureBtn" class="button button-min button-primary pull-right"
                               style="height:20px;margin-left: 10px;">上传</a>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            店铺背景图：
                        </label>

                        <div class="controls" style="overflow: hidden;height: auto;padding-bottom: 20px;">
                            <input type="hidden" class="input-normal control-text " name="background"
                                   data-rules="{required : true}" readonly style="width: 280px;" value="${e.background}"/>
                            <img id="backPicture" src="/${e.background!}"
                                 style="max-width: 250px;width: 100%;max-height: 250px;">
                            <a id="backBtn" class="button button-min button-primary pull-right"
                               style="height:20px;margin-left: 10px;">上传</a>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            经度：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="lng" placeholder="请输入经度"
                                   data-rules="{required : true,number:true}" value="${e.lng!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            纬度：
                        </label>

                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="lat" placeholder="请输入纬度"
                                   data-rules="{required : true,number:true}"    value="${e.lat!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            打印机编号SN：
                        </label>
                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="printSn"  value="${e.printSn!}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            打印机识别码KEY：
                        </label>
                        <div class="controls">
                            <input type="text" class="control-text span-width span8" name="printKey"  value="${e.printKey!}">
                        </div>
                    </div>
                    <div class="centered">
                        <button type="submit" class="button  button-large  button-success">保存</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    <#-----------------------------商品上架跳转----------------------------->
    var Grid = BUI.Grid;
    var Store = BUI.Data.Store;
    var Data = BUI.Data;
    var Calendar = BUI.Calendar;
    var editForm = new BUI.Form.Form({
        srcNode: '#editForm',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
                window.location.href = "${basepath}/rest/manage/store/toList"
            } else {
                BUI.Message.Alert(data.message, 'error');
                return;
            }
        }
    }).render();

    /*------------------------店铺头像上传插件配置  begin-----------------------*/
    //商品主图上传
    var pictureUploader = WebUploader.create({
        auto: true,
        swf: '${staticpath}/base/ueditor/third-party/webuploader/Uploader.swf',
        server: '${basepath}/rest/manage/ued/config?action=uploadimage',
        pick: '#pictureBtn',
        resize: false,
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png,'
        }
    });
    //获取一张主图并传入url
    pictureUploader.on('uploadSuccess', function (file, response) {
        pictureUploader.removeFile(file);
        editForm.setFieldValue("icon", response.url);
        $("#proPicture").attr("src", "${basepath}/" + response.url);
    });

    /*------------------------店铺背景图上传插件配置  begin-----------------------*/
    //商品主图上传
    var backUploader = WebUploader.create({
        auto: true,
        swf: '${staticpath}/base/ueditor/third-party/webuploader/Uploader.swf',
        server: '${basepath}/rest/manage/ued/config?action=uploadimage',
        pick: '#backBtn',
        resize: false,
        accept: {
            title: 'Images',
            extensions: 'gif,jpg,jpeg,bmp,png',
            mimeTypes: 'image/gif,image/jpg,image/jpeg,image/bmp,image/png,'
        }
    });
    //获取一张主图并传入url
    backUploader.on('uploadSuccess', function (file, response) {
        backUploader.removeFile(file);
        editForm.setFieldValue("background", response.url);
        $("#backPicture").attr("src", "${basepath}/" + response.url);
    });


</script>

</@page.pageBase>
